<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <my-conp></my-conp>
    ===============
    <mycompo></mycompo>
    <hr>
</div>

<div id="app2">
    <my-conp></my-conp>
</div>


<script src="../../js/vue.js"></script>

<script>
    //1.创建组件构造器
    const componentConstructor = Vue.extend({
        template: `<div>
        <h2>内容1----</h2>
        <p>内容2----</p>
    </div>`
    });
    
    //2.注册全局组件,可以在多个vue实例下面使用
    Vue.component("my-conp", componentConstructor);
    
    const vue = new Vue({
        el: "#app",
        data: {
            message: "Hello vue,你好！"
        },
        methods: {
            
        },
        components: {
            //3.注册局部组件，在此vue实例下使用
            mycompo: componentConstructor
        }
    });
    
    const vue2 = new Vue({
        el: "#app2",
        data: {
            message: "Hello vue,你好！"
        },
        methods: {
            
        }
    });
</script>
</body>
</html>